package com.ruoyi.wecom.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.ruoyi.business.domain.dto.admin.wecom.WecomExternalContactFollowUserPageQueryDTO;
import com.ruoyi.business.domain.wecom.TbWecomExternalContactFollowUser;
import com.ruoyi.business.service.wecom.ITbWecomExternalContactFollowUserService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@Validated
@Api(value = "配置了客户联系功能的成员列表管理", tags = {"配置了客户联系功能的成员列表管理"})
@RequiredArgsConstructor
@RestController
@RequestMapping("/wecom/external/contact/follow")
public class WecomExternalContactFollowController extends BaseController {

    @Resource
    private ITbWecomExternalContactFollowUserService tbWecomExternalContactFollowUserService;


    /**
     * 分页查询配置了客户联系功能的成员列表
     */
    @ApiOperation("管理台分页查询配置了客户联系功能的成员列表")
    @SaCheckPermission("wecom:external:contact:follow:page")
    @GetMapping("/sys-page")
    public TableDataInfo<TbWecomExternalContactFollowUser> sysPage(WecomExternalContactFollowUserPageQueryDTO pageQueryDTO, PageQuery pageQuery) {
        return tbWecomExternalContactFollowUserService.sysPageQuery(pageQueryDTO, pageQuery);
    }


    /**
     * 同步企微客服
     */
    @ApiOperation("同步企微客服")
    @SaCheckPermission("wecom:external:contact:follow:sync")
    @PostMapping("/sys-sync")
    public R<Boolean> sysSyncWecomData() {
        return R.ok(tbWecomExternalContactFollowUserService.sysSyncWecomExternalContactFollowUserData());
    }

}
